fix(ios): fix type mismatch in setAffinityCalculationStrategy causing crash #146
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
There's a critical type mismatch in the iOS implementation of setAffinityCalculationStrategy method that causes crashes when the affinity calculation strategy is set. The method signature in the header file declares the parameter as NSNumber * but the implementation was trying to pass an NSInteger value directly, causing a type mismatch and potential runtime crashes.
💡 Motivation and Context
This change is required to fix a critical bug in the iOS implementation where setting the affinityCalculationStrategy prop would cause the app to crash due to a type mismatch between the method signature and the actual parameter being passed. The issue occurs when React Native tries to call the native method with an integer value, but the method expects an NSNumber object.
There is a closed issue about that but that was fixed only for old architecture
My fix is for a new one
#97
📢 Changelog
iOS
Fixed type mismatch in setAffinityCalculationStrategy method signature
Updated method call to properly wrap integer value with @() to convert to NSNumber
Resolved potential crash when setting affinity calculation strategy
🤔 How Has This Been Tested?
The fix has been tested by:
Verifying that the method signature in the header file matches the expected parameter type (NSNumber *)
Ensuring the implementation properly converts the integer value to NSNumber using the @() syntax
Confirming that the type mismatch error is resolved and the method can be called without crashes
📸 Screenshots (if appropriate):
This is stacktrace for the crash
How to reproduce
Build an app with the lib with new architecture enabled
If prop affinityCalculationStrategy set, app crashes
📝 Checklist